package com.flkin.modules.system.repository;

import com.flkin.modules.system.domain.Authority;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.Set;

/**
 * @author yanxiang.huang 2020-12-07 22:32:08
 */
public interface AuthorityRepository extends JpaRepository<Authority, Long>, JpaSpecificationExecutor<Authority> {

    @Query(value = "SELECT a.* " +
            "FROM `authority` a, `role_authority` ra " +
            "WHERE a.id = ra.authority_id AND ra.role_id = ?1"
            , nativeQuery = true)
    Set<Authority> findByRoleId(Long id);
}
